<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        {{lastName}} - {{firstName}}
        <hr />
        {{fullName}}
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        data: {
          firstName: "li",
          lastName: "jack",
        },
        // 计算属性，响应式数据
        computed: {
          fullName: {
            get() {
              return `${this.lastName} ${this.firstName}`;
            },
            set(value) {
              [this.lastName, this.firstName] = value.split(" ");
            },
          },
        },
        created() {
          setTimeout(() => {
            // this.lastName = "lili";
            this.fullName = "lili zhang";
          }, 3000);
        },
      });
    </script>
  </body>
</html>
